package com.example.controller;

import com.example.loader.HazelcastTopicLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.UUID;

@RestController
public class TestTopicController {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Resource
    private HazelcastTopicLoader hazelcastTopicLoader;

    /***
     * 发送topic消息
     * @return
     * @throws Exception
     */
    @RequestMapping("sendTopic")
    public String sendTopic() throws Exception {
        String uuid = UUID.randomUUID().toString();
        hazelcastTopicLoader.getTopic().publish(uuid);
        return uuid;
    }
}
